import 'package:flutter/material.dart';

class TutorialPage3 extends StatefulWidget {
  @override
  _TutorialPage3State createState() => _TutorialPage3State();
}

class _TutorialPage3State extends State<TutorialPage3> {
  int count = 0;

  GlobalKey<_TextDemoState> _globalKey = GlobalKey();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Page3')),
      body: Center(
        child: Wrap(
          direction: Axis.vertical,
          children: [
            TextDemo(count: count),
            FlatButton(
                onPressed: () {
                  setState(() {
                    count++;
                  });
                },
                child: Text("ADD 1")),
          ],
        ),
      ),
    );
  }
}

class TextDemo extends StatefulWidget {
  final int count;
  final Key key;

  const TextDemo({this.count, this.key});

  @override
  _TextDemoState createState() => _TextDemoState();
}

class _TextDemoState extends State<TextDemo> {
  @override
  Widget build(BuildContext context) {
    return Text("number ${widget.count}");
  }
}
